package com.leyou.service;

import com.leyou.myException.LyException;
import com.leyou.pojo.Item;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @author jshstart
 * @creat 2020-12-08 20:49
 */
@Service
public class ItemService {
    public Item saveItem(Item item) {
        if (item.getPrice()==null){
            throw new LyException(400,"价格不能为空。。。");
        }else if (item.getName()==null){
            throw new LyException(400,"商品名不能为空。。。");
        }
        item.setId(new Random().nextInt(100));
        return item;
    }
}
